1
|
|
|
var path = require('path'); |
2
|
|
|
var fs = require('fs'); |
3
|
|
|
var JSZip = require("jszip"); |
4
|
|
|
var rsync = require("rsyncwrapper"); |
5
|
|
|
var chalk = require('chalk'); |
6
|
|
|
var node_ssh = require('node-ssh'); |
7
|
|
|
var ssh = new node_ssh(); |
|
|
|
|
8
|
|
|
|
9
|
|
|
ssh.connect({ |
10
|
|
|
host: 'www.d1b0.local', |
11
|
|
|
username: 'developer', |
12
|
|
|
privateKey: './server/plays/ssh/developer.key', |
13
|
|
|
port: 2222 |
14
|
|
|
}).then(function() { |
15
|
|
|
var nextCommand = ssh.mkdir('/var/www/workspace.local/src/'); |
16
|
|
|
// @see: https://github.com/steelbrain/node-ssh/blob/master/src/index.js |
17
|
|
|
nextCommand.then( function(){ |
18
|
|
|
ssh.exec('rm', ['-rf', 'public'], { cwd: '/var/www/workspace.local', stream: 'stdout' }).then( function(output){ |
|
|
|
|
19
|
|
|
ssh.exec('ln', ['-s','web','public'], { cwd: '/var/www/workspace.local', stream: 'stdout' }).then( function(output){ |
|
|
|
|
20
|
|
|
ssh.dispose(); |
21
|
|
|
}); |
22
|
|
|
}); |
23
|
|
|
}); |
24
|
|
|
}); |
25
|
|
|
|
26
|
|
|
rsync({ |
27
|
|
|
src: "./applications/workspace/", |
28
|
|
|
dest: "[email protected]:/var/www/workspace.local/", |
29
|
|
|
ssh: true, |
30
|
|
|
privateKey: './server/plays/ssh/developer.key', |
31
|
|
|
port: 2222, |
32
|
|
|
exclude: [ 'test', '.DS_Store', 'phpunit.xml', 'README.md', 'vendor' ], |
33
|
|
|
recursive: true, |
34
|
|
|
deleteAll: false //senno elimina log! |
35
|
|
|
},function (error,stdout,stderr,cmd) { |
36
|
|
|
if ( error ) { |
37
|
|
|
process.stderr.write('CMD: '+cmd+"\n"); |
38
|
|
|
process.stderr.write(chalk.red(error.message)); |
39
|
|
|
process.exit(1); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
}); |
42
|
|
|
|
43
|
|
|
ssh.connect({ |
44
|
|
|
host: 'www.d1b0.local', |
45
|
|
|
username: 'developer', |
46
|
|
|
privateKey: './server/plays/ssh/developer.key', |
47
|
|
|
port: 2222 |
48
|
|
|
}).then(function() { |
49
|
|
|
ssh.exec('composer', ['install', '--no-dev', '--optimize-autoloader', '--no-interaction', '--no-progress', '--no-scripts'], { cwd: '/var/www/workspace.local/', stream: 'stdout' }).then(function(output) { |
50
|
|
|
process.stdout.write(chalk.cyan(output)); |
51
|
|
|
ssh.dispose(); |
52
|
|
|
}); |
53
|
|
|
}); |
54
|
|
|
|